#!/bin/sh
function copy_depend() {
    # copy dependency
    if [ -e $1 ]; then
        cp --parents $1 $SYS_ROOT
        echo "Copy dependency $1 to ${SYS_ROOT}$1."
    fi
    # recursively
    local depend=`ldd $1`
    for line in $depend
    do
        if [ -e $line ]; then
            if [ -e ${SYS_ROOT}${line} ]; then
                echo "Dependency $line already copied."
            else
                copy_depend $line
            fi
        fi    
    done
}
